package com.ruoyi.airspaceFlight.service.impl;

import com.ruoyi.airspaceFlight.domain.AirspaceApply;

import com.ruoyi.airspaceFlight.dto.req.FlightStatisticsDto;
import com.ruoyi.airspaceFlight.dto.req.RegisterStaisticsDto;
import com.ruoyi.airspaceFlight.dto.req.ViolationStatisticsDto;
import com.ruoyi.airspaceFlight.dto.resp.FlightStatisticsVo;
import com.ruoyi.airspaceFlight.dto.resp.RegisterStaisticsVo;
import com.ruoyi.airspaceFlight.dto.resp.ViolationStatisticsVo;
import com.ruoyi.airspaceFlight.mapper.FlyApplyMapper;
import com.ruoyi.airspaceFlight.mapper.StatisticsMapper;
import com.ruoyi.airspaceFlight.service.StatisticsService;
import com.ruoyi.common.core.exception.base.BaseException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *统计Service业务层
 */
@Service
public class StatisticsServiceImpl implements StatisticsService {
    @Autowired
    private FlyApplyMapper flyApplyMapper;

    @Autowired
    private StatisticsMapper statisticsMapper;
    /**
     * 飞行统计
     * @param flightStatisticsDto
     * @return
     */
    @Override
    public List<FlightStatisticsVo> selectflightStatisticsList(FlightStatisticsDto flightStatisticsDto) {
        if (flightStatisticsDto.getType() == 0){
            return flyApplyMapper.selectBytask(flightStatisticsDto);
        }else if(flightStatisticsDto.getType() == 1){
            return flyApplyMapper.selectByDay(flightStatisticsDto);
        } else if (flightStatisticsDto.getType() == 2){
            return flyApplyMapper.selectByMonth(flightStatisticsDto);
        }else if (flightStatisticsDto.getType() == 3){
            return flyApplyMapper.selectByYear(flightStatisticsDto);
        }
        new BaseException("参数错误");
           return null;
    }


    /**
     * 违规统计
     * @param violationStatisticsDto
     * @return
     */
    @Override
    public List<ViolationStatisticsVo> selectViolationStatisticsList(ViolationStatisticsDto violationStatisticsDto) {
        if(violationStatisticsDto.getType() == 0){
            List<ViolationStatisticsVo> violationStatisticsVos = statisticsMapper.selectViolationStatisticsList(violationStatisticsDto);
            return violationStatisticsVos;
        }else if(violationStatisticsDto.getType() == 1){
            List<ViolationStatisticsVo> violationStatisticsVos = statisticsMapper.selectByMonth(violationStatisticsDto);
            return violationStatisticsVos;
        }else if(violationStatisticsDto.getType() == 2){
            List<ViolationStatisticsVo> violationStatisticsVos = statisticsMapper.selectByYear(violationStatisticsDto);
            return violationStatisticsVos;
        }

        return null;


    }


    /**
     * 注册统计
     * @param registerStaisticsDto
     * @return
     */
    @Override
    public List<RegisterStaisticsVo> selectRegisterStatisticsList(RegisterStaisticsDto registerStaisticsDto) {
        if(registerStaisticsDto.getType() == 0){
            return statisticsMapper.selectRegisterByDay(registerStaisticsDto);
        }else if(registerStaisticsDto.getType() == 1){
            return statisticsMapper.selectRegisterByMonth(registerStaisticsDto);
        }else if(registerStaisticsDto.getType() == 2){
            return statisticsMapper.selectRegisterByYear(registerStaisticsDto);
        }

        return null;
    }
}
